package com.sixth.volunteerservicesystem.ServiceImpl;

import com.sixth.volunteerservicesystem.Dao.NewsRepository;
import com.sixth.volunteerservicesystem.Service.NewsService;
import com.sixth.volunteerservicesystem.domain.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NewsServiceimpl implements NewsService {
    @Autowired
    NewsRepository newsRepository;
    @Override
    public void sava(News news) {
        newsRepository.save(news);
    }

    @Override
    public void delete(int id) {
     newsRepository.deleteById(id);
    }

    @Override
    public List<News> list() {
        List<News> newlist = newsRepository.findAll();
        return newlist;
    }

    @Override
    public News Getone(int id) {
        News news = newsRepository.getOne(id);
        return news;
    }
}
